package java69.work722.CarManager;

public class Coach extends Automobile {
    private int seating;//座位数

    public Coach() {
    }

    public Coach(String num, String brand, double rent,boolean store, int seating) {
        super(num, brand, rent,store);
        this.seating = seating;
    }

    public int getSeating() {
        return seating;
    }

    public void setSeating(int seating) {
        this.seating = seating;
    }

    static Coach[] coach = new Coach[]{
            new Coach("京6566754","金杯",800,true,16),
            new Coach("京8696997","金杯",800,true,16),
            new Coach("京9696996","金杯",1500,true,32),
            new Coach("京8696998","金杯",1500,true,32),
    };
    @Override
    public void sum(String num, int days) {
        double sum;
        boolean pd = false;
        for (int i = 0; i <coach.length ; i++) {
            if (coach[i].getNum().equals(num)){
                pd = true;
                if(days>150){
                    sum = coach[i].getRent() * days * 0.6;
                }else  if(days>30){
                    sum = coach[i].getRent() * days * 0.7;
                }else if(days>7){
                    sum = coach[i].getRent() * days * 0.8;
                }else if (days>3){
                    sum = coach[i].getRent() * days*0.9;
                }else {
                    sum = coach[i].getRent() * days;
                }
                System.out.println("欢迎租借车牌号："+coach[i].getNum()+",日租金为："+coach[i].getRent()+"元,在库状态为"
                        +coach[i].isStore()+"的"+coach[i].getSeating()+"座车辆："+coach[i].getBrand()+",共"
                        +days+"天，总计须缴费："+sum+"元。");
                break;
            }
        }
        if (pd) {
            System.out.println("租车成功！");
        }else {
            System.out.println("车牌号为"+num+"的轿车不存在！");
        }
    }
}
